#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <cstring>
#include <cstdlib>
#include <string>
#include <iostream>

using namespace boost::interprocess;

int main()
{
	/*struct shm_remove
	{
		shm_remove() { shared_memory_object::remove("MySharedMemory"); }
		~shm_remove() { shared_memory_object::remove("MySharedMemory"); }
	} remover;*/

	shared_memory_object shm(open_or_create, "MySharedMemory", read_write);
	shm.truncate(10);

	mapped_region region(shm, read_write);
	std::memset(region.get_address(), 1, region.get_size());

	std::cout << "Memoria creada por programa 1" << std::endl;
	char *mem = static_cast<char*>(region.get_address());
	for (size_t i = 0; i < region.get_size(); ++i, ++mem)
	{
		std::cout << *mem << std::endl;
	}

	return 1;
}